package com.grgbanking.it.system.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.grgbanking.it.base.BaseDao;
import com.grgbanking.it.system.dao.IDepartmentDao;
import com.grgbanking.it.system.entity.Department;


/**
 * 
 * @author JRainbow 
 */
@Repository 
public class DepartmentDao extends BaseDao<Department, Integer> implements IDepartmentDao<Department, Integer> {
    @Autowired  
    public void setMySessionFactory(SessionFactory oaSessionFactory){  
        super.setSessionFactory(oaSessionFactory);  
    }
   
    public List<Department> findByParent(Integer parentId){
    	StringBuffer hql = new StringBuffer("from Department t ");
    	hql.append("where t.deptParent=").append(parentId);
    	
    	return this.findByHql(hql.toString());
    }
    
    public List<Department> findAll(){
    	StringBuffer hql = new StringBuffer("from Department t ");
    	
    	return this.findByHql(hql.toString());
    }

	
}